﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:extra="clr-namespace:WPFImageWindows;assembly=WPFImageWindows"
        xmlns:local="clr-namespace:WPFXMPPClient"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WPFXMPPClient.AudioMuxerWindow"
        Loaded="Window_Loaded" MouseDown="Window_MouseDown"
        AllowsTransparency="True" WindowStyle="None"
        ResizeMode="CanResizeWithGrip"
        Title="Audio Muxer Window" Height="332" Width="1027">
   
    <Window.Resources>
        <BitmapImage x:Key="MuteImage" UriSource="Images/mic-muted.png" />
        <BitmapImage x:Key="LiveImage" UriSource="Images/mic-live.png" />

    </Window.Resources>

    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFBBFF81" Offset="0"/>
            <GradientStop Color="#FFEEFFDF" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30" />
            <RowDefinition Height="100*" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200*" />
                    <ColumnDefinition Width="30" />
                </Grid.ColumnDefinitions>
                <Label FontWeight="Bold" HorizontalAlignment="Center" Content="Audio Session Muxer"/>

                <Button Style="{DynamicResource ButtonSurface}" ToolTip="Close" Grid.Column="1" x:Name="ButtonClose" Click="ButtonClose_Click"  HorizontalAlignment="Center" Padding="0" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Grid.RowSpan="2">
                    <Image Source="Images/calculator - multiply.png" Width="20" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </Button>
        </Grid>


        <TabControl Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <TabItem Header="Sessions">
                <Grid>

                    <Grid.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFBBFF81" Offset="0"/>
                            <GradientStop Color="#FFEEFFDF" Offset="1"/>
                        </LinearGradientBrush>
                    </Grid.Background>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="253*" />
                    </Grid.RowDefinitions>


                    <Grid Margin="2" Grid.Row="0" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150*"/>
                            <ColumnDefinition Width="220"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.5*"/>
                            <RowDefinition Height="0.5*"/>
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Column="1" Grid.RowSpan="2">
                            <Label HorizontalAlignment="Center" FontSize="10" FontWeight="Bold">Music Controls</Label>
                            <local:AudioPlayerUserControl x:Name="AudioPlayer" Height="82" />
                        </StackPanel>


                        <Grid Height="40" Margin="0,0,0,4" Grid.Row="0" Grid.ColumnSpan="2" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="60" />
                                <ColumnDefinition Width="150" />
                                <ColumnDefinition Width="40" />
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition Width="60" />
                                <ColumnDefinition Width="100*" />
                            </Grid.ColumnDefinitions>
                            <Label Width="60" Content="Speaker" HorizontalAlignment="Left"/>
                            <ComboBox Grid.Column="1" Background="#AAEEFFEE" x:Name="ComboBoxSpeakerDevices" SelectionChanged="ComboBoxSpeakerDevices_SelectionChanged" SelectedValuePath="Guid" SelectedValue="{Binding SpeakerDevice}" />
                            <!--<s:SurfaceCheckBox Margin="5,0" x:Name="CheckBoxAutoAnswer" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">Auto Answer</s:SurfaceCheckBox>-->
                            <ToggleButton Grid.Column="2" ToolTip="Speaker Off" Background="#AACCFFCC" BorderBrush="{x:Null}" x:Name="ButtonMuteSpeaker" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding SpeakerMute}" HorizontalAlignment="Left">
                                <Image Width="32" Height="32" >
                                    <Image.Style>
                                        <Style>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding SpeakerMute}" Value="True">
                                                    <Setter Property="Image.Source" Value="Images/speakermute.png" />
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding SpeakerMute}" Value="False">
                                                    <Setter Property="Image.Source" Value="Images/speaker.png" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                            </ToggleButton>
                            <StackPanel Grid.Column="3" Orientation="Vertical" >
                                <Slider Margin="0,2,0,0" x:Name="SliderSpeakerVolume" Minimum="0" Maximum="100" Value="{Binding Volume, Mode=TwoWay}"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
                                <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Speaker Volume"/>
                            </StackPanel>
                            <ToggleButton Grid.Column="4" ToolTip="Auto Answer" Background="#AACCFFCC" BorderBrush="{x:Null}" x:Name="ButtonAutoAnswer" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding AutoAnswer}" >
                                <Image Width="32" Height="32" >
                                    <Image.Style>
                                        <Style>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding AutoAnswer}" Value="True">
                                                    <Setter Property="Image.Source" Value="Images/offhook.png" />
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding AutoAnswer}" Value="False">
                                                    <Setter Property="Image.Source" Value="Images/onhook.png" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                            </ToggleButton>

                            <extra:AudioViewerControl x:Name="OurAudioViewer" Width="100" Grid.Column="5" HorizontalAlignment="Left"  />
                            
                        </Grid>

                        <Grid Height="40" Grid.Row="1" Grid.ColumnSpan="2" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="60" />
                                <ColumnDefinition Width="150" />
                                <ColumnDefinition Width="40" />
                                <ColumnDefinition Width="80" />
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="100" />
                                <ColumnDefinition Width="100*" />
                            </Grid.ColumnDefinitions>
                            
                            <Label  Content="Mic" HorizontalAlignment="Left"/>
                            <ComboBox Grid.Column="1" Background="#AAEEFFEE" x:Name="ComboBoxMicDevices" SelectionChanged="ComboBoxMicDevices_SelectionChanged" SelectedValuePath="Guid" SelectedValue="{Binding MicrophoneDevice}"/>
                            <ToggleButton Grid.Column="2" ToolTip="Mute" Background="#AACCFFCC" BorderBrush="{x:Null}" x:Name="ButtonMute" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding Muted}" >
                                <Image x:Name="ImageMicMute" Width="32" Height="32">
                                    <Image.Style>
                                        <Style>
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Muted}" Value="True">
                                                    <Setter Property="Image.Source" Value="Images/mic-muted.png" />
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Muted}" Value="False">
                                                    <Setter Property="Image.Source" Value="Images/mic-live.png" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Image.Style>
                                </Image>
                            </ToggleButton>

                            <StackPanel Grid.Column="3" Orientation="Vertical">
                                <Slider Margin="0,2,0,0" x:Name="SliderMicVolume" Minimum="0" Maximum="100" Value="{Binding Volume, Mode=TwoWay}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
                                <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Mic Volume"/>
                            </StackPanel>
                            <CheckBox Grid.Column="4"  IsChecked="{Binding UseAEC}" x:Name="CheckBoxUseAEC" Checked="CheckBoxUseAEC_Checked" Unchecked="CheckBoxUseAEC_Unchecked"  VerticalAlignment="Center" Content="AEC" ToolTip="Activate Acoustic Echo Cancellation" d:LayoutOverrides="Width"/>
                            <CheckBox Grid.Column="5"  IsChecked="{Binding UseAGC}" x:Name="CheckBoxUseAGC" Checked="CheckBoxUseAGC_Checked"  Unchecked="CheckBoxUseAGC_Unchecked"  VerticalAlignment="Center" Content="AGC" ToolTip="Activate Automatic Gain Control" d:LayoutOverrides="Width"/>
                            <CheckBox Grid.Column="6" Checked="CheckBoxCancelOutMusic_Checked" Unchecked="CheckBoxCancelOutMusic_Unchecked"  x:Name="CheckBoxCancelOutMusic" VerticalAlignment="Center" Content="Cancel Out Music" ToolTip="Prevents music from playing back to the speaker.  Only conference members can hear the music" d:LayoutOverrides="Width"/>
                        </Grid>

                    </Grid>


                    <ListView x:Name="ListViewAudioSessions" Grid.Row="1" Margin="5" >
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Video" Width="180">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <extra:VideoControl x:Name="VideoControlUser" Width="160" Height="100" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Remote User" Width="180"  >
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Source="{Binding RosterItem.Avatar}" Width="64" Height="64" />
                                                <StackPanel Orientation="Vertical">
                                                    <Label FontSize="10" VerticalAlignment="Center" FontWeight="Bold" Content="{Binding RemoteJID}" />
                                                    <Label FontSize="8" VerticalAlignment="Center" Content="{Binding CallDuration}" />
                                                    <Label FontSize="8" VerticalAlignment="Center" Content="{Binding RemoteEndpoint}" />
                                                </StackPanel>
                                            </StackPanel>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="State" Width="100" DisplayMemberBinding="{Binding SessionState}" />
                                <GridViewColumn Header="Audio" Width="120"  >
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <extra:AudioViewerControl Width="120" Height="48" Loaded="AudioViewerControl_Loaded" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Actions" Width="320">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <StackPanel Orientation="Vertical">
                                                    <!--<Button Background="#AACCFFCC" BorderBrush="{x:Null}" x:Name="ButtonMute" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                            <Image Width="28" Height="28" Source="Images/mic-live.png" />
                                        </Button>-->
                                                    <ToggleButton Background="#AACCFFCC" Height="32" Width="32" BorderBrush="{x:Null}" x:Name="ButtonMute" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding AudioRTPStream.Muted}">
                                                        <Image x:Name="ImageMicMute" Width="28" Height="28">
                                                            <Image.Style>
                                                                <Style>
                                                                    <Style.Triggers>
                                                                        <DataTrigger Binding="{Binding AudioRTPStream.Muted}" Value="True">
                                                                            <Setter Property="Image.Source" Value="Images/mic-muted.png" />
                                                                        </DataTrigger>
                                                                        <DataTrigger Binding="{Binding AudioRTPStream.Muted}" Value="False">
                                                                            <Setter Property="Image.Source" Value="Images/mic-live.png" />
                                                                        </DataTrigger>
                                                                    </Style.Triggers>
                                                                </Style>
                                                            </Image.Style>
                                                        </Image>
                                                    </ToggleButton>
                                                    <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top">
                                                        <Label.Style>
                                                            <Style>
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding AudioRTPStream.Muted}" Value="True">
                                                                        <Setter Property="ContentControl.Content" Value="Muted" />
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding AudioRTPStream.Muted}" Value="False">
                                                                        <Setter Property="ContentControl.Content" Value="Can Speak" />
                                                                    </DataTrigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Label.Style>
                                                    </Label>

                                                </StackPanel>
                                                <StackPanel Orientation="Vertical">
                                                    <ToggleButton Height="32" Width="32" Background="#AACCFFCC" BorderBrush="{x:Null}" x:Name="ButtonDeafen" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding AudioRTPStream.Deafened}">
                                                        <Border Width="28" Height="28" >
                                                            <Border.Style>
                                                                <Style>
                                                                    <Style.Triggers>
                                                                        <DataTrigger Binding="{Binding AudioRTPStream.Deafened}" Value="True">
                                                                            <Setter Property="Border.Background" Value="{DynamicResource earmuffs}" />
                                                                        </DataTrigger>
                                                                        <DataTrigger Binding="{Binding AudioRTPStream.Deafened}" Value="False">
                                                                            <Setter Property="Border.Background" Value="{DynamicResource noearmuffs}" />
                                                                        </DataTrigger>
                                                                    </Style.Triggers>
                                                                </Style>
                                                            </Border.Style>
                                                        </Border>
                                                    </ToggleButton>
                                                    <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top">
                                                        <Label.Style>
                                                            <Style>
                                                                <Style.Triggers>
                                                                    <DataTrigger Binding="{Binding AudioRTPStream.Deafened}" Value="True">
                                                                        <Setter Property="ContentControl.Content" Value="Deafened" />
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding AudioRTPStream.Deafened}" Value="False">
                                                                        <Setter Property="ContentControl.Content" Value="Can Hear" />
                                                                    </DataTrigger>
                                                                </Style.Triggers>
                                                            </Style>
                                                        </Label.Style>
                                                    </Label>
                                                </StackPanel>
                                                <StackPanel Orientation="Vertical">
                                                    <Slider Height="32" x:Name="SliderVolume" Minimum="0" Maximum="2" Value="{Binding AudioRTPStream.SourceAmplitudeMultiplier}" Width="60" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
                                                    <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Input Volume"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Vertical">
                                                    <Slider Height="32" x:Name="SliderOutputVolume" Minimum="0" Maximum="2" Value="{Binding AudioRTPStream.SinkAmplitudeMultiplier}" Width="60" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
                                                    <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Output Volume"/>
                                                </StackPanel>
                                                <StackPanel Orientation="Vertical">
                                                    <Button Background="#AACCFFCC"  Height="32" Width="32" BorderBrush="{x:Null}" x:Name="ButtonClose" Click="ButtonClose_Click_1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                                        <Image Width="28" Height="28" Source="Images/connected.png" />
                                                    </Button>
                                                    <Label FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Top" Content="Disconnect"/>
                                                </StackPanel>
                                            </StackPanel>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Statistics" Width="280" >
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Vertical">
                                                <Label Content="{Binding Statistics}" FontSize="8"  />
                                                <Button Style="{DynamicResource ButtonLink}" x:Name="ButtonResetStats" Content="Reset" Click="ButtonResetStats_Click"  />
                                            </StackPanel>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                            </GridView>
                        </ListView.View>

                    </ListView>

                </Grid>
            </TabItem>

            <TabItem Header="Video" Visibility="Visible">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="240" />
                        <ColumnDefinition Width="767" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30" />
                        <RowDefinition Height="30" />
                        <RowDefinition Height="182*" />
                    </Grid.RowDefinitions>

                    <ComboBox x:Name="ComboBoxVideoSources" SelectionChanged="ComboBoxVideoSources_SelectionChanged"></ComboBox>
                    <StackPanel Orientation="Horizontal" Grid.Row="1">
                        <ComboBox x:Name="ComboBoxResolution" Width="150" />
                        
                        <Button x:Name="ButtonStartStopVideo" Width="70" Click="ButtonStartStopVideo_Click">Send</Button>
                    </StackPanel>

                    <!--<extra:VideoControl x:Name="OurVideo" Grid.Row="2" />-->
                    
                    <ListBox Grid.Column="1" Grid.Row="2" x:Name="ListBoxUserVideo"></ListBox>
                    
                </Grid>
                
                
                
            </TabItem>

        </TabControl>

     </Grid>

</Window>
